package dao;

import entity.Vegetable;
import util.DBMannager;

import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class VegetableAddDao {
    public boolean addVegetable(Vegetable vegetable) throws SQLException {
        boolean flag = false;
        Connection connection=DBMannager.getConnection();
        String sql="insert into vegetable values(?,?,?,?,?)";
        PreparedStatement ps=null;

        ps=connection.prepareStatement(sql);
        ps.setString(1,vegetable.getVegename());
        ps.setDate(2, (Date) vegetable.getPlanttime());
        ps.setInt(3,vegetable.getNumber());
        ps.setBigDecimal(4,vegetable.getPrice());
        ps.setInt(5,vegetable.getVstatus());

        if(ps.executeUpdate()!=0){
            flag=true;
        }else {
            flag=false;
        }

        return flag;
    }
}
